package com.example.demo.service.impl;

import com.example.demo.dao.CourseCatDao;
import com.example.demo.entity.CourseCatBean;
import com.example.demo.service.CourseCatService;
import com.example.demo.util.PageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseCatServiceImpl implements CourseCatService {
    @Autowired
    private CourseCatDao courseCatDao;

    @Override
    public Integer add(CourseCatBean courseCatBean) {
        return courseCatDao.add(courseCatBean);
    }

    @Override
    public Integer update(CourseCatBean courseCatBean) {
        return courseCatDao.update(courseCatBean);
    }

    @Override
    public Integer delete(Integer id) {
        return courseCatDao.delete(id);
    }

    @Override
    public CourseCatBean one(Integer id) {
        return courseCatDao.getOneById(id);
    }

    @Override
    public PageEntity list(Integer pageNo, Integer pageSize, String name, String sortOrder) {
        Integer count = courseCatDao.count(name);
        List<CourseCatBean> list = courseCatDao.list(name, sortOrder);
        return new PageEntity<>(list, count);
    }
} 